import pandas as pd

# read in data
meta = pd.read_csv('../../data/metadata/nasal/nasal_metadata.csv', index_col='SampleID')
meta['age_at_collection'] = (pd.to_datetime(meta['CollectionDate']) - pd.to_datetime(meta['DOB'])).dt.days

titer_data_2 = pd.read_csv('../../data/vaccine_response/vaccine_response_y2.tsv', sep='\t', index_col=0) # TODO: check with KB that this is fixed/the right version
titer_data_2.index = [int(i.split('Baby')[-1]) for i in titer_data_2.index]

nasal_titer_data_2 = pd.DataFrame({sample: titer_data_2.loc[row['BabyN']] for sample, row in meta.iterrows() if row['BabyN'] in titer_data_2.index}).transpose()

nasal_titer_data_2.to_csv('../../data/metadata/nasal/nasal_titers_yr2.csv', index_label='SampleID')
